package com.app.ryjy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 特殊工种标识枚举
 */
@AllArgsConstructor
@Getter
public enum SpecialOccupationEnum {
    // 有毒
    TOXIC("有毒", "1"),
    // 有害
    HARMFUL("有害", "2"),
    // 井下
    UNDERGROUND("井下", "3"),
    // 高温
    HIGH_TEMPERATURE("高温", "4"),
    // 高空
    HIGH_ALTITUDE("高空", "5"),
    // 特别繁重体力劳动
    HEAVY_PHYSICAL_LABOR("特别繁重体力劳动", "6"),
    // 其他
    OTHER("其他", "9");

    private final String desc;
    private final String code;

    /**
     * 根据 code 获取 desc
     *
     * @param code code
     * @return desc
     */
    public static String getDescByCode(String code) {
        for (SpecialOccupationEnum occupation : values()) {
            if (occupation.getCode().equals(code)) {
                return occupation.getDesc();
            }
        }
        throw new RuntimeException("code 不存在");
    }

    public static void main(String[] args) {
        System.out.println(SpecialOccupationEnum.getDescByCode("4"));  // 输出：高温
    }
}
